--TEST--
Check for error and PDO watching
--FILE--
<?php
// prepare
pdl_enable(true);
pdl_watch(PDL_W_PDO | PDL_W_ERROR);
$output_dir = realpath(ini_get('pdlogger.output_dir'));

$sqlite_db = $output_dir . '/test.db';

function commit($db) {
	$pdo = new PDO('sqlite:' . $db);
	$create_test = <<<TEST
CREATE TABLE test
(
	name varchar(30),
	pass varchar(32)
)
TEST;
	$pdo->exec($create_test);	// will record this method
	try {
		@$pdo->prepare("INSERT INTO test values(?, ?)");
	} catch (Exception $ex) {
	}
	try {
		@$pdo->commit();	// will record this method
	} catch (Exception $ex) {
	}
	try {
		@$pdo->rollBack();	// will record this method
	} catch (Exception $ex) {
	}
	try {
		@$pdo->beginTransaction();	// will record this method
	} catch (Exception $ex) {
	}
	try {
		@$pdo->exec("DELETE FROM test where id = 1");	// will record this method
	} catch (Exception $ex) {
	}
	try {
		@$pdo->query("SELECT * FROM test");	// will record this method
	} catch (Exception $ex) {
	}
}

pdl_start(true);

commit($sqlite_db);

pdl_stop(true);

$period = (int) ini_get('pdlogger.period');
$time = time();
$time = ($time - ($time % $period));
$text_log_file = $output_dir . "/text/$time.log";

echo file_get_contents($text_log_file);

if (is_file($text_log_file)) {
	unlink($text_log_file);
}
if (is_file($sqlite_db)) {
	unlink($sqlite_db);
}
?>
--EXPECTF--
# Copyright (c) 2012, Zoujie Wu. Generated by PDLogger 1.0.0
#
#   Record from %s
#   Change log after %d sec(s)


@start %d+%d
[%s] [Info] [PDO] Create PDO object in %f msec(s), SUCCESS @%s008.php:%d
  Connect database with sqlite driver
  - data source: %stest.db
  - username: (null)
  - persistent: false, id = (null)
  - auto commit: true
[%s] [Info] [PDO] Execute SQL in %s msec(s), SUCCESS @%s008.php:%d
  SQL: CREATE TABLE test
  (
  	name varchar(30),
  	pass varchar(32)
  )
[%s] [Info] [PDO] Prepare SQL statement in %f msec(s), SUCCESS @%s008.php:%d
  SQL: INSERT INTO test values(?, ?)
[%s] [Exception] [PDO] Commit transaction in %f msec(s), FAILURE @%s008.php:%d
  Exception: PDOException
  Message: There is no active transaction
  Throw At: %s008.php:%d
  Trace:
  #0 %s008.php(%d): PDO->commit()
  #1 %s008.php(%d): commit('%s')
  #2 {main}
[%s] [Exception] [PDO] Roll back transaction in %f msec(s), FAILURE @%s008.php:%d
  Exception: PDOException
  Message: There is no active transaction
  Throw At: %s008.php:%d
  Trace:
  #0 %s008.php(%d): PDO->rollBack()
  #1 %s008.php(%d): commit('%s')
  #2 {main}
[%s] [Info] [PDO] Begin transaction in %f msec(s), SUCCESS @%s008.php:%d
[%s] [Warning] [PDO] Execute SQL in %f msec(s), FAILURE @%s008.php:%s
  SQLSTATE[HY000]: no such column: id
[%s] [Info] [PDO] Query SQL in %f msec(s), SUCCESS @%s008.php:%d
  SQL: SELECT * FROM test
